﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <link href="~/layui/lib/layui-v2.6.3/css/layui.css" rel="stylesheet" />
    <link href="~/layui/css/public.css" rel="stylesheet" />
    <link href="~/steps/steps.css" rel="stylesheet" />
    <style>
        body {
            background-color: #ffffff;
        }

        .step-icon-custom-box {
            width: 40px;
            height: 40px;
        }

        .step-icon-custom {
            margin-top: -2px;
            font-size: 26px;
        }

        .box {
            width: 100%;
            margin-left: auto;
        }
    </style>
</head>
<body>


    <div class="layui-form layuimini-form" lay-filter="formTest">

        <div class="layui-fluid" style="width:95%">
            <div id="steps14"></div>
        </div>

        <div class="layui-row layui-col-space10">
            <div class="layui-col-md4">
            </div>
            <div class="layui-col-md4">
                <div class="box">
                    <div class="layui-form-item">
                        <label class="layui-form-label ">申请人</label>
                        <div class="layui-input-block">
                            <input type="text" name="ReviewerName" lay-verify="required" disabled value="" class="layui-input ">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label ">申请物资</label>
                        <div class="layui-input-block">
                            <input type="text" name="ConsumableName" lay-verify="required" disabled value="" class="layui-input  ">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label layui-required">申请理由</label>
                        <div class="layui-input-block">
                            <input type="text" name="ReviewReasons" lay-verify="ReviewReason" disabled value="" class="layui-input  ">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label ">物资数量</label>
                        <div class="layui-input-block">
                            <input type="text" name="Num" lay-verify="required"  value="" id="day" class="layui-input  ">
                        </div>
                    </div>

                    <div class="layui-form-item" id="status">
                        <label class="layui-form-label">是否同意</label>
                        <div class="layui-input-block">
                            <input type="radio" name="reviewStatusb" value="2" title="同意" checked>
                            <input type="radio" name="reviewStatusb" value="3" title="驳回">
                        </div>
                    </div>
                    <div class="layui-form-item" >
                        <label class="layui-form-label layui-required">同意理由</label>
                        <div class="layui-input-block">
                            <textarea placeholder="请输入描述" oninput="wordLeg(this);" maxlength="100" onpropertychange="if(value.length>100) value=value.substr(0,100)" name="reviewReason" class="layui-textarea"></textarea>
                            <div class="word"><span class="text_count">0</span>&nbsp;/&nbsp;<span class="num_count" id="numCounts">100</span></div>
                        </div>
                    </div>

                    <div class="layui-form-item layui-hide">
                        <div class="layui-input-block">
                            <input type="hidden" name="Id">
                        </div>
                    </div>
                    <div class="layui-form-item layui-hide">
                        <div class="layui-input-block">
                            <input type="hidden" name="Id">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认审核</button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-col-md4">
            </div>
        </div>




    </div>


    <script src="~/lib/jquery/dist/jquery.js"></script>
    <script src="~/steps/steps.js"></script>
    <script src="~/layui/lib/layui-v2.6.3/layui.js"></script>
    <script>
        layui.use(['form'], function () {
            var form = layui.form,
                layer = layui.layer,
                $ = layui.$;
            
            //接收主页传过来的数据
            var id = GetQueryString("id");
            var _instanceIds = GetQueryString("_instanceIds");

            //封装GetQueryString()方法来获取URL后面的value值
            function GetQueryString(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                var r = window.location.search.substr(1).match(reg);
                if (r != null)
                    return decodeURI(r[2]);
                return null;
            }

            //步骤条
            $.ajax({
                url: "/WorkFlow_InstanceStep/getStepList",
                type: "get",
                data: { InstanceId: _instanceIds },
                success: function (res) {
                    var data = res.data.step;
                    for (var i = 0; i < res.data.length; i++) {
                        console.log("000:" + res.data[i].title)
                    }
                   steps({
                        el: "#steps14",
                        data,
                       active: res.data.status,
                        iconType: "",
                        customClass: "custom-class"
                    });
                }
            })

            //描述字数
            window.wordLeg = function (obj) {
                var currleg = $(obj).val().length;
                var length = $(obj).attr('maxlength');
                if (currleg > length) {
                    layer.msg('字数请在' + length + '字以内');
                } else {
                    $('.text_count').text(currleg);
                }
            }

            //渲染列表
            $.ajax({
                url: "/WorkFlow_InstanceStep/getUpdataWorkFlow_InstanceSteptList",
                type: "get",
                data: { instanceSteID: id },
                success: function (res) {
                    console.log(res)
                    //给表单赋值
                    form.val("formTest", {
                        "Id": id,
                        "ReviewerName": res.data._reviewerName
                        , "ConsumableName": res.data._consumableName
                        , "ReviewReasons": res.data._reviewReason
                        , "Num": res.data._outNum
                    });
                    if (res.data._updataStuaus) {
                        $('#day').removeAttr('disabled');
                        $('#status').hide();   
                    } else {
                        $("#day").attr("disabled", "disabled");
                        $("#status").show();
                    }
                }
            }),

            //监听提交（修改）
            form.on('submit(saveBtn)', function (data) {
                $.ajax({
                    url: "/WorkFlow_InstanceStep/UpdataWorkFlow_InstanceStep",
                    type: "put",
                    data: data.field,
                    success: function (res) {
                        if (res.data) {
                            layer.alert(res.msg, { icon: 1 }, function () {
                                var iframeIndex = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(iframeIndex);
                            })
                        } else {
                            layer.msg(res.msg, { icon: 5 });
                        }
                    }
                }),
                    // 关闭弹出层
                    layer.close(index);
            });

        });</script>
</body>
</html>


